//
//  UIBarButtonItem+Extension.swift
//  Tanenbaum_blog
//
//  Created by Tanenbaum on 15/8/5.
//  Copyright © 2015年 GZJ. All rights reserved.
//

import UIKit
extension UIBarButtonItem {
    
    convenience init(imageName:String,target: AnyObject?, action: String?) {
        
        let button = UIButton()
        
        button.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        button.setImage(UIImage(named: imageName +  "_highlighted"), forState: UIControlState.Highlighted)
        
        button.sizeToFit()
        if let actionName = action {
            button.addTarget(target, action: Selector(actionName), forControlEvents: UIControlEvents.TouchUpInside)
        }
        
        self.init(customView: button)
    }
    
}